import { ElMessage, ElMessageBox, ElNotification } from 'element-plus'
export const message = (msg: string, type?: string) => {
  switch (type) {
    case 'warning':
      ElMessage.warning(msg)
      break
    case 'success':
      ElMessage.success(msg)
      break
    case 'error':
      ElMessage.error(msg)
      break
    case 'info':
      ElMessage.info(msg)
      break
    default:
      ElMessage.warning(msg)
      break
  }
}

export function messageConfirm(content: any) {
  return new Promise((resolve, reject) => {
    ElMessageBox.confirm(content, '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'info'
    })
      .then(() => {
        resolve(true)
      })
      .catch(() => {
        reject(false)
      })
  })
}

export const notificationSuccess = (title: string, content: string) => {
  return ElNotification({
    title: title,
    message: content,
    type: 'success'
  })
}
